package com.service.business.banklock.controller;

import com.service.business.banklock.controller.rep.MemberBankLockRep;
import com.service.business.banklock.controller.req.MemberBankLockDetailsReq;
import com.service.business.banklock.controller.req.PageBankLockReq;
import com.service.business.banklock.controller.req.MemberBankLockReq;
import com.service.business.banklock.controller.req.PageBankLockTypeReq;
import com.service.business.banklock.service.MemberBankLockService;
import com.service.business.banklock.service.MemberBankLockTypeService;
import com.service.business.framework.log.RequestLog;
import com.service.business.support.SessionUtil;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.BaseResponse;
import com.service.core.rest.response.PageResponse;
import com.service.dao.model.MemberBankLock;
import com.service.dao.model.MemberBankLockType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/bank-lock")
@Api(tags = "用户锁仓")
public class BankLockController extends BaseController {

	@Autowired
	private MemberBankLockService memberBankLockService;

	@Autowired
	private MemberBankLockTypeService memberBankLockTypeService;

	@Autowired
	private SessionUtil sessionUtil;

	@ApiOperation("新增锁仓订单")
	@RequestLog("新增锁仓订单")
	@PostMapping("/new-lock")
	public BaseResponse lock(@ApiParam @RequestBody @Validated MemberBankLockReq req){
		memberBankLockService.addLock(req);
		return successBaseResponse();
	}

	@ApiOperation("锁仓订单列表")
	@RequestLog("锁仓订单列表")
	@PostMapping("/list-lock")
	public PageResponse<MemberBankLockRep> list(@ApiParam @RequestBody @Validated PageBankLockReq req){
		return successQueryPageResponse(memberBankLockService.listLock(req));
	}

	@ApiOperation("锁仓订单详情")
	@RequestLog("锁仓订单详情")
	@PostMapping("/details-lock")
	public BaseResponse details(@ApiParam @RequestBody MemberBankLockDetailsReq req){
		return successQueryOneResponse(memberBankLockService.details(req));
	}

	@ApiOperation("锁仓周期选择列表")
	@RequestLog("锁仓周期选择列表")
	@PostMapping("/list-type")
	public PageResponse<MemberBankLockType> listType(@ApiParam @RequestBody PageBankLockTypeReq req){
		return successQueryPageResponse(memberBankLockTypeService.list(req));
	}
}
